package com.g9.blog.common;

import com.g9.blog.enums.CodeMsg;

/**
 * 响应客户端结果集封装--(操作返回结果result工具类)
 */
public class Response {
    private final static String SUCCESS = "success";

    private final static String FAIL = "fail";

    public static <T> Result<T> makeOKRsp() {
        return new Result<T>().setCode(CodeMsg.SUCCESS).setMsg(SUCCESS);
    }

    public static <T> Result<T> makeOKRsp(String message) {
        return new Result<T>().setCode(CodeMsg.SUCCESS).setMsg(message);
    }

    public static <T> Result<T> makeOKRsp(T data) {
        return new Result<T>().setCode(CodeMsg.SUCCESS).setMsg(SUCCESS).setData(data);
    }

    public static <T> Result<T> makeErrRsp(String message) {
        return new Result<T>().setCode(CodeMsg.INTERNAL_SERVER_ERROR).setMsg(message);
    }

    public static <T> Result<T> makeRsp(int code, String msg) {
        return new Result<T>().setCode(code).setMsg(msg);
    }

    public static <T> Result<T> makeRsp(int code, String msg, T data) {
        return new Result<T>().setCode(code).setMsg(msg).setData(data);
    }
}
